package cn.jiyun.controller;


import cn.jiyun.common.config.Result;
import cn.jiyun.entity.XmSettled;
import cn.jiyun.service.IXmSettledService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-25
 */
@RestController
@RequestMapping("/xm-client/xm-settled")
public class XmSettledController {

    @Autowired
    private IXmSettledService xmSettledService;

//    查询所有店铺
    @RequestMapping("findAll")
    public Result findAll(Integer current, Integer pageSize,@RequestBody XmSettled xmSettled){
        Page<XmSettled> xmSettledPage=xmSettledService.findAll(current,pageSize,xmSettled);
        return Result.ok(xmSettledPage);
    }


//    修改店铺的状态
    @RequestMapping("updateSettled")
    public Result updateSettled(@RequestBody XmSettled xmSettled){
        xmSettledService.updateById(xmSettled);
        return Result.ok();
    }


//    修改这个店铺的审核状态
    @RequestMapping("audit")
    public Result audit(@RequestBody XmSettled xmSettled){
        xmSettledService.updateById(xmSettled);
        return Result.ok();
    }



//    查询店铺所有数据
    @RequestMapping("findAllClient")
    public List<XmSettled> findAllClient(){
        List<XmSettled> list = xmSettledService.list();
        return list;
    }



//    根据id查询所有的数据
    @RequestMapping("findSettledById")
    public Result findById(Integer id){
        XmSettled xmSettled=xmSettledService.getById(id);
        return Result.ok(xmSettled);
    }

    @RequestMapping("query")
    public Result query(){
        QueryWrapper<XmSettled> xmSettledQueryWrapper = new QueryWrapper<>();
        xmSettledQueryWrapper.eq("shop_status",2);
        xmSettledQueryWrapper.eq("audit_status",8);
        List<XmSettled> list = xmSettledService.list(xmSettledQueryWrapper);
        return Result.ok(list);
    }

//    统计本周新增的电店铺
    @RequestMapping("findAllSettled")
    public Result findAllSettled(){
        Integer count = xmSettledService.findAllSettled();
        return Result.ok(count);
    }


//    统计昨天新增的店铺
    @RequestMapping("findAllSettled2")
    public Result findAllSettled2(){
        Integer count = xmSettledService.findAllSettled2();
        return Result.ok(count);
    }
}
